const { regClass } = Laya;
import { StaticData } from "../../Data/StaticData";
import { GameRes } from "../../GameRes";
import { ViewGuideBase } from "./ViewGuide.generated";

@regClass()
export class ViewGuide extends ViewGuideBase {
    actGuideOver:Function = undefined;
    onAwake(): void {
        this.ViewGuide1.visible = false;
        this.ViewGuide2.visible = false;
        this.ViewGuide3.visible = false;
        this.ViewGuide4.visible = false;
        this.ViewGuide5.visible = false;

        this.BtnNext1.on(Laya.Event.CLICK,this,this.onClickNext1);
        this.BtnNext2.on(Laya.Event.CLICK,this,this.onClickNext2);
        this.BtnNext3.on(Laya.Event.CLICK,this,this.onClickNext3);
        this.BtnNext4.on(Laya.Event.CLICK,this,this.onClickNext4);
        this.BtnAgane.on(Laya.Event.CLICK,this,this.onClickAgane);
        this.BtnStartGame.on(Laya.Event.CLICK,this,this.onClickStartGame);

    }
    onDestroy(): void {
        this.BtnNext1.off(Laya.Event.CLICK,this,this.onClickNext1);
        this.BtnNext2.off(Laya.Event.CLICK,this,this.onClickNext2);
        this.BtnNext3.off(Laya.Event.CLICK,this,this.onClickNext3);
        this.BtnNext4.off(Laya.Event.CLICK,this,this.onClickNext4);
        this.BtnAgane.off(Laya.Event.CLICK,this,this.onClickAgane);
        this.BtnStartGame.off(Laya.Event.CLICK,this,this.onClickStartGame);
    }

    public viewShow(actOver:Function) {
        this.actGuideOver = actOver;
        this.visible = true;
        this.ViewGuide1.visible = true;
        this.ViewGuide2.visible = false;
        this.ViewGuide3.visible = false;
        this.ViewGuide4.visible = false;
        this.ViewGuide5.visible = false;

        this.PopSelectExceptionMessage.showGuide(StaticData.arrReasonStr)
    }
    public viewHide() { this.visible = false; }

    private onClickNext1(){
        Laya.SoundManager.playSound(GameRes.clickAudio, 1);
        this.ViewGuide1.visible = false;
        this.ViewGuide2.visible = true;
    }
    private onClickNext2(){
        Laya.SoundManager.playSound(GameRes.clickAudio, 1);
        this.ViewGuide2.visible = false;
        this.ViewGuide3.visible = true;
    }
    private onClickNext3(){
        Laya.SoundManager.playSound(GameRes.clickAudio, 1);
        this.ViewGuide3.visible = false;
        this.ViewGuide4.visible = true;
    }
    private onClickNext4(){
        Laya.SoundManager.playSound(GameRes.clickAudio, 1);
        this.ViewGuide4.visible = false;
        this.ViewGuide5.visible = true;
    }
    private onClickAgane(){
        Laya.SoundManager.playSound(GameRes.clickAudio, 1);
        this.ViewGuide1.visible = true;
        this.ViewGuide2.visible = false;
        this.ViewGuide3.visible = false;
        this.ViewGuide4.visible = false;
        this.ViewGuide5.visible = false;
    }

    private onClickStartGame(){
        Laya.SoundManager.playSound(GameRes.clickAudio, 1);
        this.viewHide();
        this.actGuideOver?.();
        this.actGuideOver = undefined;
    }
}